package com.xlk.cxf.client;

import java.util.List;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.junit.Test;

import com.xlk.cxf.domain.Reader;
import com.xlk.cxf.service.IReaderService;

public class ReaderServiceClient {
	public static void main(String[] args) {
		JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
		factoryBean.setServiceClass(IReaderService.class);
		factoryBean.setAddress("http://localhost:8080/readerService");
		
		IReaderService readerService = (IReaderService)factoryBean.create();
		Reader reader = readerService.getReader("shun","123");
		System.out.println("Reader:"+reader);
	}
	@Test
	public void clienttest1(){
		System.out.println("ddddddddd");
		JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
		factoryBean.setServiceClass(IReaderService.class);
		factoryBean.setAddress("http://127.0.0.1:8080/CXFWebservice/webservice/readerService2");
		
		IReaderService readerService = (IReaderService)factoryBean.create();
		Reader reader = readerService.getReader("shun","123");
		System.out.println("Reader:"+reader);
	}
	@Test
	public void cilentTest2(){
		JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
		factoryBean.setServiceClass(IReaderService.class);
		factoryBean.setAddress("http://127.0.0.1:8080/CXFWebservice/webservice/readerService2");
		
		IReaderService readerService = (IReaderService)factoryBean.create();
		List<Reader> readers =  readerService.getReaders();
		for (Reader reader : readers) {
			System.out.println("Reader:"+reader);
		}
	}
}
